<html>
<head>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>发布</title>
    {include file='common/header'}
    <link href="/static/home/mobile/css/reset_5.css" rel="stylesheet" type="text/css" />
    <link href="/static/home/mobile/css/style.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="/static/home/mobile/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="/static/home/mobile/css/new_page.css" />
    <link href="/static/home/mobile/css/new_style.css" rel="stylesheet" type="text/css" />
    <style>
        .member-form .item-box span{width:60px;}
        .member-form .item-box .m_txt{width: calc(100% - 60px);}
        
      .close {
		top: 10px;
    left: 140px;
    position: absolute;
    background: #e00f0f;
    display: block;
    line-height: 1;
    color: #FFF;
    text-align: center;
    padding: 2px;
    border-radius: 10px;
    cursor: pointer;
}


    </style>
</head>
<body>
    <header class="site-header header-fixed">
        <input type="hidden" id="taskId">
        <a onclick="history.back()" class="back"></a>
        <div class="tit-name" id="title_txt">发布</div>
    </header>
    <div class="new-top-up">
        <div class="update-box" id="hasZfb" style="">

            
            <form id="post_form" enctype="multipart/form-data">
           
                <div class="member-form">
                    <div class="item-box"><span>标题:</span>
                        <input type="text" name="title" id="title" value="{$data['title']?$data['title']:''}" class="m_txt" placeholder="请输入标题">
                    </div>
                </div>
                <div class="member-form" style="height:120px;">
                    <div class="item-box" style="height:120px;"><span>介绍:</span>
                    
                        <textarea id="introduce" style='height:100px;padding-top:10px;padding-bottom:10px;background:#f7f7f7;margin-top:10px;' type="text" name="introduce"  value="{$data['introduce']?$data['introduce']:''}" class="m_txt" placeholder="请输入介绍">{$data['introduce']?$data['introduce']:''}</textarea>
                    </div>
                </div>

                <div class="member-form" style="border-top:1px solid #999;">
                    <div class="item-box" style="height:70px;position:relative;"><span style="line-height:70px;">头像:</span>
                        <i id="wx"  style="display:block;">
                        <img id="photo_img" src="{$data['photo']|default="/static/img7.png"}" style="height:50px;width:50px;margin:10px;">
                        {if !empty($data['photo'])}
                        <div class=" close pic-delete-btn pointer" onclick="remove_photo(this);">&nbsp;X&nbsp;</div>
                        {/if}
                        
                        <input type="file" name="photo" id="photo" style="padding-top:14px;position:absolute;top:10px;left:80px;{if !empty($data['photo'])}display:none;opacity:0;{/if}" value="{$data['photo']?$data['photo']:''}" class="m_txt" >
                       </i>
                    </div>
                </div>
                
                <div class="member-form" >
                    <div class="item-box" style="height:70px;position:relative;"><span style="line-height:70px;">二维码:</span>
                        <i id="wx"  style="display:block;">
                       	<img id="qrcode_img" src="{$data['qrcode']|default="/static/img7.png"}" style="height:50px;width:50px;margin:10px;">
                       	{if !empty($data['qrcode'])}
                        <div class=" close pic-delete-btn pointer" onclick="remove_qrcode(this);">&nbsp;X&nbsp;</div>
                        {/if}
                        <input type="file" name="qrcode" id="qrcode"  style="padding-top:14px;position:absolute;top:10px;left:80px;{if !empty($data['qrcode'])}display:none;opacity:0;{/if}" value="{$data['qrcode']?$data['qrcode']:''}" class="m_txt" >
                       </i>
                    </div>
                </div>
                {if empty($data['connection_id'])}
                <div class="user-gold">
                    <span>付款金额：<span class="user-gold-money" style="color: red">￥&nbsp;{$fee} 元</span></span>
                </div>
                {/if}
                
                        <input type="hidden" name="type" value="{$type}">
                        <input type="hidden" name="id" value="{$data['connection_id']|default=''}">
                        
                <div class="member-form" style="background:#fff;">
                    <div class="member-btn">
                        <input type="button" class="button1" value="确认" style="color: #ffffff;background: #f96a22">
                    </div>
                </div>
           
                <div class="member-form">
                    <div class="tixian_txt">
                        温馨提示：<br />
                        1、二维码如无法上传请截图只保留二维码部分再重试,不要包含二维码外部的空白等其他部分.<br />
                        2、说明：二维码有效期为<font color="red">2</font>个月，若置顶则以置顶结束时间为止.<br />
                        3、警示：禁止发布图片或文字包含明显的<font color="#9acd32">赌、黄敏</font>感内容、存在<font color="red">欺骗行为</font>被他人投诉或<font color="red">同类平台</font>内容，发现会做屏蔽处理，如仍继续发布违规信息将做封号处理。<font color="red">如发黄色头像直接屏蔽</font>
                    </div>

                </div>
            </form>
        </div>
    </div>
    

    <script src="/static/home/mobile/js/qrcode/jquery.qrcode.min.js"></script>

    <script type="text/javascript">
var id="{$data['connection_id']|default=''}";
	function remove_photo(e){
		console.log(121)
		$('#photo_img').hide();
		$('#photo').show();
		$('#photo').css('opacity','1');
		$(e).hide()
	}


	function remove_qrcode(e){
		console.log(121)
		$('#qrcode_img').hide();
		$('#qrcode').show();
		$('#qrcode').css('opacity','1');
		$(e).hide()
	}


        if($('#realname').val()!=''){
            $('#realname').attr("readonly","readonly");
        }
        $(':radio').click(function(){
            if($('input:radio[name="pay_method"]:checked').val()==1){
                $('#account').removeAttr("readonly");
                $('#account').val("{$data['alipay_account']?$data['alipay_account']:''}");
            }else{
                $('#account').val("{$data['title']?$data['title']:''}");

            }
        });

        
        $(function () {
            
            $('.button1').click(function () {
				if(!$('#title').val()){
					message('请输入标题','','error');
				return false;
				}
				if(!$('#introduce').val()){
					message('请输入介绍','','error');
				return false;
				}
				
				if(!$('#photo').val() && !id){
					message('请上传头像','','error');
					return false;
				}
				
				if(!$('#qrcode').val() && !id){
					message('请上传二维码','','error');
				return false;
				}
				
            var a=0;
            if(a == 1) return;
           // $('.button1').attr('disabled',true);
            a=1;
            
            var formData = new FormData($("#post_form")[0])  //创建一个forData 
         
          //  formData.append('photo', $('#photo')[0].files[0]) //把file添加进去  name命名为img
            
                
          //   formData.append('qrcode', $('#qrcode')[0].files[0]) //把file添加进去  name命名为img

            
     $.ajax({
        url: window.location.href,
        data: formData,
        type: "POST",
        async: false,
        cache: false,
        contentType: false,
        processData: false,
        success: function(ret) {
        	console.log(ret)
            a=0;
        
            message(ret.message,ret.redirect,ret.type);
        },
        error: function() {
              //失败
        }
      })
      
    
/*                $.post(
                    window.location.href,
                    $('#post_form').serialize(),
                    function (ret) {
                        a=0;
                        message(ret.message,ret.redirect,ret.type);
                    },'json'
                );
                */
                
            });
        });

            

    </script>
    <script>
            function set_pay_type(type){
                if(type == 1){
                    $("#wx").show()
                    $('#ali').hide()
                }
                
                if(type == 2){
                    $("#wx").hide()
                    $('#ali').show()
                }
            }
    </script>
</body>
</html>